package com.db.jschool.logging.helpers;

import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;

public class LoggerPropertiesLoader implements IPropertiesLoader {
	
	private static final String KEY_PROP_FILE = "logger.properties";
	
	@Override
	public Properties loadProperties() throws FileNotFoundException, IOException {
		Properties systemProperties = System.getProperties();
		Properties properties = new Properties();
		if (!systemProperties.containsKey(KEY_PROP_FILE)) {
			System.err.println("Propery file is not defined please use JVM property -Dlogger.properties=<file_name>");
			return properties;
		}
		
		properties.load(new FileReader(systemProperties.getProperty(KEY_PROP_FILE)));
		return properties;
	}
}
